package com.bjpowernode.services.impls;

import com.bjpowernode.constants.Constant;
import com.bjpowernode.entities.TClueRemark;
import com.bjpowernode.mappers.TClueRemarkMapper;
import com.bjpowernode.querys.ClueRemarkQuery;
import com.bjpowernode.services.ClueRemarkService;
import com.bjpowernode.utils.LoginInfoUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ClueRemarkServiceImpl implements ClueRemarkService {
    @Resource
    private TClueRemarkMapper tClueRemarkMapper;

    @Override
    public PageInfo<TClueRemark> getClueRemarkByPage(Integer current, Integer clueId) {
        PageHelper.startPage(current, Constant.PAGE_SIZE);
        List<TClueRemark> tClueRemarkList = tClueRemarkMapper.selectByPage(clueId);
        PageInfo<TClueRemark> page = new PageInfo<>(tClueRemarkList);
        return page;
    }

    @Override
    public int addClueRemark(ClueRemarkQuery clueRemarkQuery) {
        TClueRemark tClueRemark = new TClueRemark();
        BeanUtils.copyProperties(clueRemarkQuery, tClueRemark);
        tClueRemark.setCreateBy(LoginInfoUtil.getCurrentLoginUser().getId());
        return tClueRemarkMapper.insertSelective(tClueRemark);
    }
}
